# Maintainer: Daurnimator <daurnimator@archlinux.org>
# Contributor: Sergej Pupykin <arch+pub@p5n.pp.ru>
# Contributor: Bartłomiej Piotrowski <nospam@bpiotrowski.pl>
# Contributor: Chris Brannon <cmbrannon79@gmail.com>
# Contributor: Paulo Matias <matiasΘarchlinux-br·org>
# Contributor: Anders Bergh <anders1@gmail.com>

pkgbase=lua-filesystem
pkgname=(lua-filesystem lua51-filesystem lua52-filesystem lua53-filesystem)
pkgver=1.8.0
_tag=${pkgver//./_}
pkgrel=3
pkgdesc='File System Library for the Lua Programming Language'
arch=('loong64' 'x86_64')
url='http://keplerproject.github.io/luafilesystem/'
license=('MIT')
makedepends=('lua' 'lua51' 'lua52' 'lua53')
source=("$pkgbase-${_tag}.tar.gz::https://github.com/keplerproject/luafilesystem/archive/v${_tag}.tar.gz")
sha256sums=('16d17c788b8093f2047325343f5e9b74cccb1ea96001e45914a58bbae8932495')

build() {
  cp -a luafilesystem-${_tag} luafilesystem-${_tag}-51
  make -C luafilesystem-${_tag}-51 PREFIX=/usr LIB_OPTION="-shared ${LDFLAGS}" LUA_VERSION=5.1

  cp -a luafilesystem-${_tag} luafilesystem-${_tag}-52
  make -C luafilesystem-${_tag}-52 PREFIX=/usr LIB_OPTION="-shared ${LDFLAGS}" LUA_VERSION=5.2

  cp -a luafilesystem-${_tag} luafilesystem-${_tag}-53
  make -C luafilesystem-${_tag}-53 PREFIX=/usr LIB_OPTION="-shared ${LDFLAGS}" LUA_VERSION=5.3

  make -C luafilesystem-${_tag} PREFIX=/usr LIB_OPTION="-shared ${LDFLAGS}" LUA_VERSION=5.4
}

package_lua-filesystem() {
  cd luafilesystem-${_tag}
  make DESTDIR="$pkgdir" PREFIX=/usr LUA_VERSION=5.4 install
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_lua51-filesystem() {
  cd luafilesystem-${_tag}-51
  make DESTDIR="$pkgdir" PREFIX=/usr LUA_VERSION=5.1 install
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_lua52-filesystem() {
  cd luafilesystem-${_tag}-52
  make DESTDIR="$pkgdir" PREFIX=/usr LUA_VERSION=5.2 install
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_lua53-filesystem() {
  cd luafilesystem-${_tag}-53
  make DESTDIR="$pkgdir" PREFIX=/usr LUA_VERSION=5.3 install
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
